// run: $exec < input
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct data
{
	int v, c;
};

bool operator<(data const & a, data const & b)
{
	return a.c > b.c || (a.c == b.c && a.v < b.v);
}

int n;

int main()
{
	std::ios::sync_with_stdio(false);
	while (std::cin >> n) {
		std::map<int, int> mm;
		for (int i = 0; i < n; i++) {
			int x; std::cin >> x;
			mm[x]++;
		}
		std::vector<data> v;
		for (std::map<int, int>::iterator it = mm.begin(); it != mm.end(); ++it) {
			data tmp; tmp.v = it->first; tmp.c = it->second;
			if (!tmp.c) continue;
			v.push_back(tmp);
		}
		std::sort(v.begin(), v.end());
		for (int i = 0; i < (int)v.size(); i++)
			std::cout << v[i].v << " " << v[i].c << "\n";
	}
}

